﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Common;

namespace DBConstruct
{
    /// <summary>
    ///DatabaseFactory 的摘要说明
    /// </summary>
    public abstract class DatabaseFactory
    {
        /// <summary>
        /// 无实现构造函数
        /// </summary>
        public DatabaseFactory() { }

        /// <summary>
        /// 打开连接
        /// </summary>
        public abstract void OpenConnection();

        /// <summary>
        /// 关闭连接
        /// </summary>
        public abstract void CloseConnection();

        /// <summary>
        /// 清除命令中的参数组
        /// </summary>
        public abstract void ClearParameters();

        /// <summary>
        /// 清除命令
        /// </summary>
        public abstract void DisposeCommand();

        /// <summary>
        /// 对数据库进行查询，将得到信息通过DataSet存储在内存中返回
        /// </summary>
        /// <param name="commandString">命令字符串</param>
        /// <param name="dbParameter">参数组</param>
        /// <returns>DataSet容器数据集</returns>
        public abstract DataSet ExcuteReader(string commandString, object[] dbParameter);

        /// <summary>
        /// 对数据库检索，查找是否存在指定值
        /// </summary>
        /// <param name="commandString">命令字符串</param>
        /// <param name="dbParameter">参数组</param>
        /// <returns>布尔值</returns>
        public abstract bool IsExist(string commandString, object[] dbParameter);

        /// <summary>
        /// 进行无查询操作，包括插入、更新、删除及存储过程等，返回影响的行数
        /// </summary>
        /// <param name="commandString">命令字符串</param>
        /// <param name="dbParameter">参数组</param>
        /// <returns>int类型数据，表示影响的行数</returns>
        public abstract int ExcuteNonQuery(string commandString, object[] dbParameter);

        /// <summary>
        /// 获取当前连接字符串
        /// </summary>
        /// <returns>连接字符串</returns>
        public abstract string GetConnString();

        /// <summary>
        /// 设置当前连接字符串
        /// </summary>
        /// <param name="connString">传入的连接字符串</param>
        public abstract void SetConnString(string connString);

    }
}
